<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>uldisk网盘存储系统</title>
    <link rel="stylesheet" href="/static/plugs/layui-v2.6.8/css/layui.css">
    <script src="/static/plugs/jquery-3.4.1/jquery-3.4.1.min.js"></script>
    <script src="/static/plugs/layui-v2.6.8/layui.js"></script>
    <script src="/static/common/js/app.js"></script>
    <style>
        .login-btn {
            display: block;
        }
    </style>
</head>

<body>
    <link rel="stylesheet" href="__STATIC__/admin/css/login.css?v={$version}" media="all">
    <div class="main-body">
        <div class="login-main">
            <div class="login-top">
                <span>{:sysconfig('site','site_name')}</span>
                <span class="bg1"></span>
                <span class="bg2"></span>
            </div>
            <form class="layui-form login-bottom">
                {empty name='current_user'}

                <div class="center">

                    <div class="item">
                        <span class="icon icon-2"></span>
                        <input type="text" name="username" lay-verify="required" placeholder="请输入登录账号" maxlength="24" />
                    </div>

                    <div class="item">
                        <span class="icon icon-3"></span>
                        <input type="password" name="password" lay-verify="required" placeholder="请输入密码" maxlength="20">
                        <span class="bind-password icon icon-4"></span>
                    </div>

                    <div id="validatePanel" class="item" style="width: 137px;">
                        <input type="text" name="captcha" placeholder="请输入验证码" maxlength="4">
                        <img id="refreshCaptcha" class="validateImg" src="{:url('index/captcha')}" onclick="this.src='{:url(\'index/captcha\')}?seed='+Math.random()">
                    </div>


                </div>
                <div class="layui-form-item" style="text-align:center; width:100%;height:100%;margin:0px;">
                    <button class="login-btn" lay-submit lay-filter="login">立即登陆</button>
                    <button class="login-btn" lay-submit lay-filter="register">立即注册</button>
                </div>
                {else /}
                <div class="center"></div>
                <div class="layui-form-item" style="text-align:center; width:100%;height:100%;margin:0px;">
                    <a class="login-btn" href="/dav">进入面板</a>
                    <div class="login-btn" lay-submit lay-filter="logout">退出</div>
                </div>
                {/empty}
            </form>
        </div>
    </div>
    <div class="footer">
        {:sysconfig('site','site_copyright')}<span class="padding-5">|</span><a target="_blank" href="http://www.miitbeian.gov.cn">{:sysconfig('site','site_beian')}</a>
    </div>

    <script>
        layui.form.on('submit(register)', function (data) {

            data.field.type = 'register';
            submit(data.field);
            return false;
        })
        layui.form.on('submit(login)', function (data) {

            data.field.type = 'login';
            submit(data.field);
            return false;
        })
        layui.form.on('submit(logout)', function (data) {

            data.field.type = 'logout';


            layer.confirm('确定要退出吗？', function () {
                submit(data.field);
            });
            return false;
        })

        function submit(data) {
            loading.show();
            $.post('{:url("login")}', data, function (result) {
                loading.hide();
                layer.msg(result.msg);
                if (result.code != 0) {
                    return false;
                }

                setTimeout(() => {
                    location.reload();
                }, 1200);

            })
        }
    </script>
</body>

</html>